package com.cloudkinto.bo.api;

import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.util.Date;
import java.util.List;

/**
 * 查询分页批发单
 *
 * @author long
 */
@Data
public class TransferOrderOutboundApiQueryBo {

    @ApiModelProperty(value = "当前页")
    public Integer current = 1;

    @ApiModelProperty(value = "每页条数")
    public Integer pageSize = 20;

    @ApiModelProperty(value = "目前只支持 1(待处理) 6(已取消), 传其他值 默认1")
    private Integer status;

    @ApiModelProperty(value = "出库单号")
    private List<String> outboundNoList;

    @ApiModelProperty(value = "时间类型 1创建 2提交 3期望 4拣货 5出库 6取消")
    private Integer timeType;

    @ApiModelProperty("开始时间")
    private String startDate;

    @ApiModelProperty("结束时间")
    private String endDate;

    public String getStartDate() {
        if (StringUtils.isBlank(startDate)) {
            return DateUtil.format(DateUtil.offsetDay(new Date(), -30), "yyyy-MM-dd");
        }
        return startDate;
    }

    public String getEndDate() {
        if (StringUtils.isBlank(endDate)) {
            return DateUtil.format(DateUtil.offsetDay(new Date(), 1), "yyyy-MM-dd");
        }
        return endDate;
    }

    public Integer getPageSize() {
        if (pageSize > 200) {
            return 200;
        }
        if (pageSize < 1) {
            return 10;
        }
        return pageSize;
    }
}
